/**
 * 数字输入框组件
 * */
import {ICellInputProps} from "@/biz-components/claim-items/components-v2/cell-input/ICellInputProps";
import {Input} from "antd";

export function NumberInput(props: ICellInputProps<any>) {
	let {value, onChange, disabled} = props;
	if(typeof value === 'number') {

	} else if(value === '') {

	} else if(typeof value === 'string') {
		let temp = Number(value);
		if(isNaN(temp)) {
			value = '';
		} else {
			value = temp;
		}
	} else {
		value = ''
	}
	return (
		<Input disabled={disabled} type={"number"} value={value} onChange={(e) => {
			if(e.target.value === '') {
				onChange(e.target.value);
				return;
			}
			let currentVal = Number(e.target.value);

			if(!isNaN(currentVal)) {
				onChange(currentVal);
			}
		}}/>
	)
}
// @ts-ignore
NumberInput.defaultValue = null;
